<form name="harvesterForm"
      data-ng-keypress="updatingHarvester()">
  <input type="hidden" name="_csrf" value="{{csrf}}"/>

  <div class="row">
    <div id="gn-harvest-settings-selected-id" class="col-lg-6 gn-nopadding-left" data-gn-harvester-identification="harvesterSelected"/>
    <div id="gn-harvest-settings-selected-schedule" class="col-lg-6 gn-nopadding-right" data-gn-harvester-schedule="harvesterSelected"/>
  </div>

  <fieldset id="gn-harvest-settings-ogc-basic-row">
    <legend id="gn-harvest-settings-ogc-basic-title"><span data-translate="">harvesterMainConfigurationFor</span> {{('harvester-' +
      harvesterSelected['@type']) | translate}}
    </legend>

    <div id="gn-harvest-settings-ogc-basic-service-row" data-ng-class="harvesterSelected.site.url == '' ? 'has-error' : ''">
      <label id="gn-harvest-settings-ogc-basic-service-label" class="control-label" data-translate="">serviceUrl</label>
      <input id="gn-harvest-settings-ogc-basic-service-input" type="text" class="form-control" data-ng-model="harvesterSelected.site.url"/>
      <p class="help-block" data-translate="">serviceUrlHelp</p>
    </div>

    <div id="gn-harvest-settings-ogc-basic-type-row" data-ng-class="harvesterSelected.site.ogctype == '' ? 'has-error' : ''">
      <label id="gn-harvest-settings-ogc-basic-type-label" class="control-label" data-translate="">serviceType</label>
      <select id="gn-harvest-settings-ogc-basic-type-list" class="form-control" data-ng-model="harvesterSelected.site.ogctype">
        <option
          data-ng-repeat="t in ['WMS1.0.0', 'WMS1.1.1', 'WMS1.3.0', '-', 'WMTS1.1.0', '-', 'WFS1.0.0', 'WFS1.1.0', '-', 'WCS1.0.0', '-', 'CSW2.0.2', '-', 'WPS0.4.0', 'WPS1.0.0', 'WPS2.0.0','-', 'SOS1.0.0'] track by $index"
          value="{{t}}"
          data-ng-selected="t == harvesterSelected.site.ogctype">
          {{t | translate}}
        </option>
      </select>
      <p class="help-block" data-translate="">serviceTypeHelp</p>
    </div>
  </fieldset>

  <fieldset id="gn-harvest-settings-ogc-advanced-row">
    <legend id="gn-harvest-settings-ogc-advanced-title"><span data-translate="">harvesterAdvancedConfigurationFor</span>
      {{harvesterSelected['@type'] | translate}}
    </legend>

    <div id="gn-harvest-settings-ogc-advanced-remote-row" data-gn-harvester-account="harvesterSelected"/>

    <!-- Service metadata record -->
    <div id="gn-harvest-settings-ogc-advanced-template-row"
         data-ng-show="harvesterSelected.site.ogctype.match('^(WMS|WFS|WCS|CSW|SOS|WPS)') != null">
      <label id="gn-harvest-settings-ogc-advanced-template-label" class="control-label">
        <span data-translate="">ogcwxs-serviceTemplateUuid</span>
      </label>
      <select id="gn-harvest-settings-ogc-advanced-template-list"
              class="form-control"
              data-ng-model="harvesterSelected.options.serviceTemplateUuid"
              data-ng-options="t['geonet:info'].uuid as t.getTitle() for t in ogcwxsTemplates">
      </select>
      <p class="help-block" data-translate="">ogcwxs-serviceTemplateUuidHelp</p>
    </div>

    <div id="gn-harvest-settings-ogc-advanced-category-row"
         data-gn-category="harvesterSelected.categories[0]['@id']" data-lang="{{lang}}"
         data-label="ogcwxs-serviceCategory"/>

    <!-- Dataset metadata records -->
    <div id="gn-harvest-settings-ogc-advanced-record-row">
      <label class="control-label">
        <input id="gn-harvest-settings-ogc-advanced-record-checkbox"
               type="checkbox"
               data-ng-disabled="harvesterSelected.site.ogctype.match('^(WMS|WMTS|WFS|WCS|SOS|WPS2)') == null"
               data-ng-model="harvesterSelected.options.useLayer"/>
        <span id="gn-harvest-settings-ogc-advanced-record-label" data-translate="" translate-values="{metadataTemplateType: metadataTemplateType}">ogcwxs-createMetadataForEachLayer</span>
      </label>
      <p class="help-block" data-translate="" translate-values="{metadataTemplateType: metadataTemplateType}">
        ogcwxs-createMetadataForEachLayerHelp</span>
    </div>

    <div id="gn-harvest-settings-ogc-advanced-records-row"
         class="well"
         data-ng-show="harvesterSelected.options.useLayer">
      <div id="gn-harvest-settings-ogc-advanced-records-imports-row"
           data-ng-hide="harvesterSelected.site.ogctype.indexOf('WMTS') === 0">
        <label class="control-label">
          <input id="gn-harvest-settings-ogc-advanced-records-imports-checkbox" type="checkbox" data-ng-model="harvesterSelected.options.useLayerMd"/>
          <span id="gn-harvest-settings-ogc-advanced-records-imports-label" data-translate="" translate-values="{metadataTemplateType: metadataTemplateType}">ogcwxs-createMetadataForEachLayerUsingMetadataURL</span>
        </label>
        <p class="help-block" data-translate="" translate-values="{metadataTemplateType: metadataTemplateType}"
        >ogcwxs-createMetadataForEachLayerUsingMetadataURLHelp</p>
      </div>

      <div id="gn-harvest-settings-ogc-advanced-records-template-row"
           data-ng-show="harvesterSelected.site.ogctype.match('^(WMS|WFS|WCS|SOS|WPS)') != null">
        <label id="gn-harvest-settings-ogc-advanced-records-template-label" class="control-label">
          <span data-translate="">ogcwxs-datasetTemplateUuid</span>
        </label>
        <select id="gn-harvest-settings-ogc-advanced-records-template-list"
                class="form-control"
                data-ng-model="harvesterSelected.options.datasetTemplateUuid"
                data-ng-options="t['geonet:info'].uuid as t.getTitle() for t in ogcwxsDatasetTemplates">
        </select>
        <!--
        TODO: This need more work as it requires changes in the XSL transformation
        to inject process info in a serviceIdentification and not a dataIdentification.
        <select id="gn-harvest-settings-ogc-advanced-records-template-list-wps2"
                data-ng-show="harvesterSelected.site.ogctype.match('^(WPS2)') != null"
                class="form-control"
                data-ng-model="harvesterSelected.options.datasetTemplateUuid"
                data-ng-options="t['geonet:info'].uuid as t.getTitle() for t in ogcwxsTemplates">
        </select>-->
        <p class="help-block" data-translate="">ogcwxs-datasetTemplateUuidHelp</p>
      </div>

      <div id="gn-harvest-settings-ogc-advanced-records-thumbnail-row"
           data-ng-hide="harvesterSelected.site.ogctype.indexOf('WMS') !== 0">
        <label class="control-label">
          <input id="gn-harvest-settings-ogc-advanced-records-thumbnail-checkbox"
                 type="checkbox"
                 data-ng-disabled="harvesterSelected.site.ogctype.indexOf('WMS') !== 0"
                 data-ng-model="harvesterSelected.options.createThumbnails"/>
          <span id="gn-harvest-settings-ogc-advanced-records-thumbnail-label" data-translate="">ogcwxs-createThumbnails</span>
        </label>
        <p class="help-block" data-translate="">ogcwxs-createThumbnailsHelp</p>
      </div>

      <div id="gn-harvest-settings-ogc-advanced-records-category-row"
           data-gn-category="harvesterSelected.options.datasetCategory"
           data-lang="{{lang}}"
           data-label="ogcwxs-datasetCategory"/>
    </div>

    <!-- Those properties are only required if a template is not used. -->
    <div id="gn-harvest-settings-ogc-advanced-topic-row" data-ng-show="harvesterSelected.options.serviceTemplateUuid == '' || harvesterSelected.options.datasetTemplateUuid == ''">
      <label id="gn-harvest-settings-ogc-advanced-topic-label" class="control-label" data-translate="">ogcwxs-topicCategory</label>
      <div
        id="gn-harvest-settings-ogc-advanced-topic-list"
        data-schema-info-combo="codelist"
        data-selected-info="harvesterSelected.options.topic"
        data-gn-schema-info="gmd:MD_TopicCategoryCode"
        lang="lang"></div>
    </div>

    <div id="gn-harvest-settings-ogc-advanced-lang-row" data-ng-show="harvesterSelected.options.serviceTemplateUuid == '' || harvesterSelected.options.datasetTemplateUuid == ''">
      <label id="gn-harvest-settings-ogc-advanced-lang-label"class="control-label" data-translate="">ogcwxs-metadataLanguage</label>
      <input id="gn-harvest-settings-ogc-advanced-lang-input"
             type="text"
             class="form-control"
             data-ng-model="harvesterSelected.options.lang"
             data-gn-language-picker=""/>
    </div>

    <div id="gn-harvest-settings-ogc-advanced-schema-row" data-ng-show="harvesterSelected.options.serviceTemplateUuid == '' || harvesterSelected.options.datasetTemplateUuid == ''">
      <label id="gn-harvest-settings-ogc-advanced-schema-label" class="control-label" data-translate="">ogcwxs-outputSchema</label>
      <input id="gn-harvest-settings-ogc-advanced-schema-input" type="text" class="form-control"
             data-ng-model="harvesterSelected.options.outputSchema"/>
    </div>

    <div id="gn-harvest-settings-ogc-advanced-validate-row">
      <label id="gn-harvest-settings-ogc-advanced-validate-label" class="control-label">
        <span data-translate="">harvesterValidate</span>
      </label>
      <div id="gn-harvest-settings-ogc-advanced-validate-list" data-gn-harvester-validation="harvesterSelected.content.validate"/>
      <p class="help-block" data-translate="">harvesterValidateHelp</p>
    </div>

    <div id="gn-harvest-settings-ogc-advanced-xsl-row">
      <label id="gn-harvest-settings-ogc-advanced-xsl-label" class="control-label" data-translate="">applyXSLToRecord</label>
      <div id="gn-harvest-settings-ogc-advanced-xsl-list" data-gn-import-xsl="harvesterSelected.content.importxslt"/>
      <p class="help-block" data-translate="">applyXSLToRecordHelp</p>
    </div>
  </fieldset>

  <div id="gn-harvest-settings-ogc-privileges-row" data-gn-harvester-privileges="harvesterSelected" data-lang="{{lang}}"/>
</form>
